<?php
include_once('addon/metabox/meta-box.php');
$prefix = 'building_';
$tinymce_options = array(
  'height' => "300",
  'theme' => "advanced",
  'plugins' => "table",
  // Theme options
  'theme_advanced_buttons1' => "bold,italic,link,|,formatselect,|,bullist,numlist,outdent,indent",
  'theme_advanced_buttons2' => "tablecontrols",
  'theme_advanced_buttons3' => "",
  'theme_advanced_toolbar_location' => "top",
  'theme_advanced_toolbar_align' => "left",
  'theme_advanced_statusbar_location' => "bottom",
  'theme_advanced_resizing' => true,
);
global $meta_boxes;
$meta_boxes = array();
$meta_boxes[] = $meta_boxes[] = array(	
	'id' => 'standard',
	'title' => __( 'Infomation about buildings', 'building' ),
	'pages' => array('building'),
	'context' => 'normal',
	'priority' => 'high',
	'autosave' => false,
	'fields' => array(		
		array(			
			'name'  => __( 'Code', 'building' ),				
			'id'    => "{$prefix}code",			
			//'desc'  => __( 'Code', 'building' ),
			'type'  => 'text',			
		),
		array(			
			'name'  => __( 'Featured', 'building' ),				
			'id'    => "{$prefix}is_featured",			
			//'desc'  => __( 'Is Featured', 'building' ),
			'type' => 'checkbox',
		),
		array(
			'name'     => __( 'Type', 'building' ),
			'id'       => "{$prefix}type",
			'type'     => 'select',			
			'options'  => array(
				'For Rent' => __( 'For Rent', 'building' ),
				'For Sale' => __( 'For Sale', 'building' ),				
			),			
			'multiple'    => true,
			'std'         => 'For Sale',			
		),			
		array(			
			'name'  => __( 'Cost ', 'building' ),				
			'id'    => "{$prefix}cost",			
			'desc'  => __( 'Entry Cost  ( ex : 1000 or 1000.00)', 'building' ),
			'type' => 'number',
			'min'  => 0,
			'step' => 5,		
		),
			
		array(
			'name' => __( 'Number of room', 'building' ),
			'id'   => "{$prefix}num_room",
			'type' => 'number',
			'min'  => 1,
			'step' => 5,
		),	
		array(
			'name' => __( 'Number of Bedroom', 'building' ),
			'id'   => "{$prefix}num_bedroom",
			'type' => 'number',
			'min'  => 1,
			'step' => 5,
		),	
		array(
			'name'     => __( 'Interior', 'building' ),
			'id'       => "{$prefix}interior",
			'type'     => 'select',			
			'options'  => array(
				'Fully Furnished' => __( 'Fully Furnished', 'building' ),
				'Partly Furnished' => __( 'Partly Furnished', 'building' ),
				'Unfurnished' => __( 'Unfurnished', 'building' ),
			),			
			'multiple'    => false,
			'std'         => 'Fully Furnished',			
		),	
		array(			
			'name'  => __( 'Available', 'building' ),				
			'id'    => "{$prefix}available",			
			//'desc'  => __( 'Available', 'building' ),
			'type'     => 'select',			
			'options'  => array(
				'' => __( 'Select Available', 'building' ),
				'Yes' => __( 'Yes', 'building' ),
				'No' => __( 'No', 'building' ),
				
			),			
			'multiple'    => false,
						
		),
		array(
			'name'     => __( 'Currency', 'building' ),
			'id'       => "{$prefix}currency",
			'type'     => 'select',			
			'options'  => array(
				'USD/WEEK' => __( 'USD/WEEK', 'building' ),
				'USD/MONTH' => __( 'USD/MONTH', 'building' ),
				'USD/YEAR' => __( 'USD/YEAR', 'building' ),				
			),			
			'multiple'    => false,
			'std'         => 'USD/MONTH',			
		),	
		array(			
			'name'  => __( 'Level', 'building' ),				
			'id'    => "{$prefix}level",			
			//'desc'  => __( 'Level', 'building' ),
			'type'  => 'text',			
		),	
		array(			
			'name'  => __( 'Allow test', 'building' ),				
			'id'    => "{$prefix}allow_test",			
			//'desc'  => __( 'Allow test', 'building' ),
			'type'     => 'select',			
			'options'  => array(
				'Yes' => __( 'Yes', 'building' ),
				'No' => __( 'No', 'building' ),				
			),					
		),	
		array(			
			'name'  => __( 'Land Area', 'building' ),				
			'id'    => "{$prefix}land_area",			
			'desc'  => __( 'Land Area ( dram sqm ex: 100 , 100.11 )', 'building' ),
			'type'  => 'text',			
		),
		array(			
			'name'  => __( 'Usable Area', 'building' ),				
			'id'    => "{$prefix}usable_area",			
			'desc'  => __( 'Usable Area ( dram sqm ex: 100 , 100.11 )', 'building' ),
			'type'  => 'text',			
		),
		array(			
			'name'  => __( 'Street', 'building' ),				
			'id'    => "{$prefix}street",			
			//'desc'  => __( 'Street', 'building' ),
			'type'  => 'text',			
		),
		array(			
			'name'  => __( 'Address', 'building' ),				
			'id'    => "{$prefix}address",			
			//'desc'  => __( 'Address', 'building' ),
			'type'  => 'text',			
		),
		array(			
			'name'  => __( 'District', 'building' ),				
			'id'    => "{$prefix}district",			
			//'desc'  => __( 'District', 'building' ),
			'type'  => 'text',			
		),
		array(
			'id'            => "{$prefix}map",
			'name'          => __( 'Map', 'building' ),
			'type'          => 'map',			
			'style'         => 'width: 550px; height: 300px',
			'address_field' => 'building_street,building_address,building_district',
		),
		
		array(
			'name' => __( 'Extra infomation', 'building' ),
			'id'   => "{$prefix}extra_infomation",
			'type' => 'textarea',			
		),
		array(
			'name'             => __( 'Image Upload', 'building' ),
			'id'               => "{$prefix}imgadv",
			'type'             => 'image_advanced',
			'max_file_uploads' => 15,
		),
	),
	'validation' => array(
		'rules' => array(
			"{$prefix}code" => array('required'  => true,),
			"{$prefix}type" => array('required'  => true,),
			"{$prefix}cost" => array('required'  => true,),
			"{$prefix}currency" => array('required'  => true,),
			"{$prefix}num_room" => array('required'  => true,),
			"{$prefix}num_bedroom" => array('required'  => true,),
			"{$prefix}interior" => array('required'  => true,),
			"{$prefix}allow_test" => array('required'  => true,),
			"{$prefix}land_area" => array('required'  => true,),
			"{$prefix}usable_area" => array('required'  => true,),
			"{$prefix}street" => array('required'  => true,),
			"{$prefix}address" => array('required'  => true,),
			"{$prefix}district" => array('required'  => true,),
			"{$prefix}available" => array('required'  => true,),
		),		
		'messages' => array(	
			"{$prefix}code" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}type" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}cost" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}currency" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}num_room" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}num_bedroom" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}interior" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}allow_test" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}land_area" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}usable_area" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}street" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}address" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}district" => array('required'  => __( 'This feild is required', 'building' ),),
			"{$prefix}available" => array('required'  => __( 'This feild is required', 'building' ),),		
		)
	)
);
function building_register_meta_boxes()
{
	if ( !class_exists( 'RW_Meta_Box' ) )	return;
	global $meta_boxes;
	foreach ( $meta_boxes as $meta_box ){
		new RW_Meta_Box( $meta_box );
	}
}
add_action( 'admin_init', 'building_register_meta_boxes' );
?>